<?php
$this->breadcrumbs=array(
	'Consulta Alocação',
);


Yii::app()->clientScript->registerCssFile(
    Yii::app()->request->baseUrl.'/assets/884ba3ad/gridview/styles.css'
);
/*
if (Yii::app()->user->isGuest == false){
    Yii::app()->clientScript->registerScriptFile(
        Yii::app()->request->baseUrl.'/js/tableGroup.js'
    );
    Yii::app()->clientScript->registerScript('salaJS',
            "$('table.detalheSemanal tbody td input').each(function(){
                $(this).click(clickCheck);
            });
            $('#hr_selecionados').hide();"
    );
}
*/
?>



<?php if ($modelC != null && $modelC->dtIni != null): ?>
<div style="float:right">
<h3>Prédio <?php echo $modelAm->iD_PREDIO->TX_DESCRICAO ?> - Ambiente <?php echo $modelAm->TX_NOME ?></h3>
</div>
<? endif; ?>
<h1>Consulta de Alocação por Ambiente</h1>
    <?php $form=$this->beginWidget('CActiveForm', array(
        'id'=>'consulta-form',
        'enableAjaxValidation'=>false,
    )); ?>
    <div class="search-form">
        <ul style="list-style-type:none">
            <li style="float:left;margin-left: 10px">
                <?php echo $form->labelEx($modelC,'ID_PREDIO'); ?>
                <?php
                    $dados = array('-1'=>'Selecione');
                    $dados += $modelAm->getPredios();
                    echo CHtml::dropDownList('ID_PREDIO','', $dados,
                            array(
                                'ajax' => array(
                                    'type'=>'POST', //request type
                                    'url'=>CController::createUrl('consulta/ambientesdinamicos'), //url to call.
                                    //Style: CController::createUrl('currentController/methodToCall')
                                    'update'=>'#ConsultaSala_ID_AMBIENTE', //selector to update
                                    //'data'=>'js:javascript statement' 
                                    //leave out the data key to pass all form values through
                                    )
                            ));
                ?>
                <?php echo $form->error($modelC,'ID_PREDIO'); ?>
            </li>
            <li style="float:left;margin-left: 10px">
                <?php echo $form->labelEx($modelC,'ID_AMBIENTE'); ?>
                <?php
                    echo $form->dropDownList($modelC,'ID_AMBIENTE', array());
                ?>
                <?php echo $form->error($modelC,'ID_AMBIENTE'); ?>
            </li>
            <li style="float:left;margin-left: 10px">
                <?php echo $form->labelEx($modelC,'DT_DIA'); ?>
                <?php Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
                    $this->widget('CJuiDateTimePicker',array(
                        'model'=>$modelC, //Model object
                        'attribute'=>'DT_DIA', //attribute name
                        'mode'=>'date', //use "time","date" or "datetime" (default)
                        'options'=>array(
                            //'value'=> 'now',
                        ) // jquery plugin options
                    ));
                ?>
                <?php echo $form->error($modelC,'DT_DIA'); ?>
            </li>
            <li style="float:left;margin-left: 10px">
                <?php
                    echo CHtml::submitButton('Pesquisar');
                ?>
            </li>
        </ul>
    </div>
    <?php $this->endWidget(); ?>
    <?php if ($modelC != null && $modelC->dtIni != null): ?>
    <div>
        <a href="<?php echo CController::createAbsoluteUrl('ambiente/viewPopup', array('id'=>$modelC->ID_AMBIENTE)) . '&height=300&width=400' ?>" class="thickbox" title="Informações do Ambiente">
            <img src="<?php echo Yii::app()->request->baseUrl.'/assets/884ba3ad/gridview/view.png'?>" />
            Informações do Ambiente
        </a>
    </div>
    <div>
        <span style="clear: left; float: right;">
            <a href="<?php echo CController::createAbsoluteUrl('consulta/sala', array('a'=>$modelC->ID_PREDIO,'b'=>$modelC->ID_AMBIENTE, 'c'=>$modelC->getPreviousWeek()))?>" style="margin:0 10px">Retroceder Semana</a>
            <a href="<?php echo CController::createAbsoluteUrl('consulta/sala', array('a'=>$modelC->ID_PREDIO,'b'=>$modelC->ID_AMBIENTE, 'c'=>$modelC->getNextWeek()))?>" style="margin:0 10px">Avançar semana</a>
        </span>
        </span>
    </div>
    <?php 
        if (Yii::app()->user->isGuest == false){
            $form=$this->beginWidget('CActiveForm', array(
            'id'=>'reserva-form',
            'enableAjaxValidation'=>false,
            'method'=>'post'
        ));
        }
    ?>
    <div class="grid-view">
        <table class="items consulta detalheSemanal">
            <thead>
                <tr>
                    <th class="horario">Horário</th>
                    <th>Domingo<br><?php echo $modelC->getSunday(); ?></th>
                    <th>Segunda<br><?php echo $modelC->getMonday(); ?></th>
                    <th>Terça<br><?php echo $modelC->getTuesday(); ?></th>
                    <th>Quarta<br><?php echo $modelC->getWednesday(); ?></th>
                    <th>Quinta<br><?php echo $modelC->getThursday(); ?></th>
                    <th>Sexta<br><?php echo $modelC->getFriday(); ?></th>
                    <th>Sábado<br><?php echo $modelC->getSaturday(); ?></th>
                </tr>
            </thead>
            <?php
            for ($i = 7; $i < 23; $i++) {
                for ($j = 0; $j < 2; $j++) {
                    echo '<tr class="'.($j%2==0?'even':'odd').'">';
                    echo '<td>' . date('H:i', mktime($i, $j%2==0?0:30, 0, 9, 11, 2011)) . '-' . date('H:i', mktime($j%2==0?$i:$i+1, $j%2==0?30:0, 0, 9, 11, 2011)) . '</td>';
                    echo '<td>' . $modelA->getAlocacao($i, $j, $modelC->getSunday(), $modelR) . '</td>';
                    echo '<td>' . $modelA->getAlocacao($i, $j, $modelC->getMonday(), $modelR) . '</td>';
                    echo '<td>' . $modelA->getAlocacao($i, $j, $modelC->getTuesday(), $modelR) . '</td>';
                    echo '<td>' . $modelA->getAlocacao($i, $j, $modelC->getWednesday(), $modelR) . '</td>';
                    echo '<td>' . $modelA->getAlocacao($i, $j, $modelC->getThursday(), $modelR) . '</td>';
                    echo '<td>' . $modelA->getAlocacao($i, $j, $modelC->getFriday(), $modelR) . '</td>';
                    echo '<td>' . $modelA->getAlocacao($i, $j, $modelC->getSaturday(), $modelR) . '</td>';
                    echo '</tr>';
                }
            }
            ?>
        </table>
    </div>
    <ul style="list-style-type:none">
        <li>
            <?php echo CHtml::hiddenField('ID_AMBIENTE', $modelC->ID_AMBIENTE); ?>
        </li>
        <?php if (Yii::app()->user->isGuest == false): ?>
            <li style="float:right;margin-left: 10px">
                <?php echo CHtml::submitButton('Reservar'); ?>
            </li>
        <?php endif; ?>
    </ul>
    <?php 
        if (Yii::app()->user->isGuest == false){
            $this->endWidget(); 
        }
    ?>
<?php endif; ?>
